<html>
<!-- (c) Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 Hewlett-Packard Development Company, LP -->
<head>
<title>Oracle Database System HowTo</title>
<link href="../styles/doc.css" rel="stylesheet" type="text/css" />
</head>
<body>

<h1>HowTo Use Oracle Database System with Jena2</h1>

<h2>What is Oracle?</h2>

<p><a href="http://www.oracle.com/">Oracle</a> is one of the leading, 
commercially-available SQL relational database management systems. It is 
available in a variety of configurations from small personal versions to 
fault-tolerant, enterprise-class versions. It runs on a variety of 
hardware/operating system platforms.</p>

<h2>Download and Installation of Oracle</h2>

<p>As Oracle is commercially-available software, we cannot provide generic 
download instructions. We assume that Jena users wishing to use Oracle have 
access to an existing Oracle installation or access to the software. Below we 
list some assumptions and post-installation instructions for using Oracle with 
Jena.</p>
<p>Jena2 can be run with
<a href="http://www.oracle.com/technology/products/database/xe/index.html">
Oracle XE</a>, as well as the full commercial versions, on both WindowsXP and 
Linux.</p>
<p>Jena2 has been tested with the 10.2.0.x JDBC drivers which work for Oracle9i 
for 9.2.0.x, Oracle10g (10.2.0.x and 10.1.0.x).</p>
<p>Jena2 no longer requires specific Oracle configuration.</p>
<font SIZE="2">

<h2>Connecting Your Jena Program to Oracle</h2>

<p>Jena supports both memory models and database models. In general, a Jena program 
may use both types of models identically. However, there are some differences 
in how the models are created. Creating a memory model can be done with a single 
Jena call. Creating a database model, or opening a previously created one, 
requires several steps as as follows.</p>

<p>Persistent models are <a href="creating-db-models.html">created</a> in the 
same way for any database system: </p>
<blockquote>
  <ol>
    <li>Load the JDBC driver. This enables the Jena program to communicate with 
    the database instance.</li>
    <li>Create a database connection. This creates a Java object for a database 
    connection.</li>
    <li>Create a ModelMaker for the database</li>
    <li>Create a Model for existing or new data.</li>
  </ol>
</blockquote>

<p>These steps are illustrated in the following Java code.</p>

<pre class="box">String className = <font face="Courier New">&quot;oracle.jdbc.driver.OracleDriver&quot;</font>;   // path of driver class
Class.forName (className);                              // Load the Driver
String DB_URL =     <font face="Courier New">&quot;jdbc:oracle:thin:@....&quot;</font>;                // URL of database 
String DB_USER =   &quot;????&quot;;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;         // database user id
String DB_PASSWD = &quot;????&quot;;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;          // database password
String DB =&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <font face="Courier New">&quot;Oracle&quot;</font>;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;         // database type

// Create database connection
IDBConnection conn = new DBConnection ( DB_URL, DB_USER, DB_PASSWD, DB );
ModelMaker maker = ModelFactory.createModelRDBMaker(conn) ;

// create or open the default model
Model model = maker.createDefaultModel();

// Close the database connection
conn.close();</pre>
<p></p>

<p></p>

<h2>Notes</h2>

</body>
</html>
